﻿namespace Sidvall.WorkItemManager.Data.Entity.Entities
{
    public partial class WorkItem : global::Sidvall.Data.DataRowBase, global::Sidvall.WorkItemManager.Data.IWorkItem
    {
        #region Public Members

        #region CanceledAction

        private int _CanceledAction;
        public int CanceledAction
        { 
            get
            {
                return _CanceledAction;
            }
            set
            {
                _CanceledAction = value;
            }
        }

        #endregion
        #region Description

        private string _Description;
        public string Description
        { 
            get
            {
                return _Description;
            }
            set
            {
                _Description = value;
            }
        }

        #endregion
        #region ExecutionCompletionPercentage

        private byte _ExecutionCompletionPercentage;
        public byte ExecutionCompletionPercentage
        { 
            get
            {
                return _ExecutionCompletionPercentage;
            }
            set
            {
                _ExecutionCompletionPercentage = value;
            }
        }

        #endregion
        #region ExecutionContext

        private string _ExecutionContext;
        public string ExecutionContext
        { 
            get
            {
                return _ExecutionContext;
            }
            set
            {
                _ExecutionContext = value;
            }
        }

        #endregion
        #region ExecutionContextUpdated

        private System.Nullable<System.DateTime> _ExecutionContextUpdated;
        public System.Nullable<System.DateTime> ExecutionContextUpdated
        { 
            get
            {
                return _ExecutionContextUpdated;
            }
            set
            {
                _ExecutionContextUpdated = Sidvall.Business.ValidationManager.GetValidUniversalDateTime(value, System.DateTimeKind.Utc);
            }
        }

        #endregion
        #region ExecutionOrder

        private int _ExecutionOrder;
        public int ExecutionOrder
        { 
            get
            {
                return _ExecutionOrder;
            }
            set
            {
                _ExecutionOrder = value;
            }
        }

        #endregion
        #region ExecutionStartTime

        private System.Nullable<System.DateTime> _ExecutionStartTime;
        public System.Nullable<System.DateTime> ExecutionStartTime
        { 
            get
            {
                return _ExecutionStartTime;
            }
            set
            {
                _ExecutionStartTime = Sidvall.Business.ValidationManager.GetValidUniversalDateTime(value, System.DateTimeKind.Utc);
            }
        }

        #endregion
        #region FailedAction

        private int _FailedAction;
        public int FailedAction
        { 
            get
            {
                return _FailedAction;
            }
            set
            {
                _FailedAction = value;
            }
        }

        #endregion
        #region FailedExecutionCount

        private int _FailedExecutionCount;
        public int FailedExecutionCount
        { 
            get
            {
                return _FailedExecutionCount;
            }
            set
            {
                _FailedExecutionCount = value;
            }
        }

        #endregion
        #region ForceExecution

        private bool _ForceExecution;
        public bool ForceExecution
        { 
            get
            {
                return _ForceExecution;
            }
            set
            {
                _ForceExecution = value;
            }
        }

        #endregion
        #region IsCanceled

        private bool _IsCanceled;
        public bool IsCanceled
        { 
            get
            {
                return _IsCanceled;
            }
            set
            {
                _IsCanceled = value;
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled;
        public bool IsEnabled
        { 
            get
            {
                return _IsEnabled;
            }
            set
            {
                _IsEnabled = value;
            }
        }

        #endregion
        #region LastExecutionEndTime

        private System.Nullable<System.DateTime> _LastExecutionEndTime;
        public System.Nullable<System.DateTime> LastExecutionEndTime
        { 
            get
            {
                return _LastExecutionEndTime;
            }
            set
            {
                _LastExecutionEndTime = Sidvall.Business.ValidationManager.GetValidUniversalDateTime(value, System.DateTimeKind.Utc);
            }
        }

        #endregion
        #region LastExecutionStartTime

        private System.Nullable<System.DateTime> _LastExecutionStartTime;
        public System.Nullable<System.DateTime> LastExecutionStartTime
        { 
            get
            {
                return _LastExecutionStartTime;
            }
            set
            {
                _LastExecutionStartTime = Sidvall.Business.ValidationManager.GetValidUniversalDateTime(value, System.DateTimeKind.Utc);
            }
        }

        #endregion
        #region LastResultMessage

        private string _LastResultMessage;
        public string LastResultMessage
        { 
            get
            {
                return _LastResultMessage;
            }
            set
            {
                _LastResultMessage = value;
            }
        }

        #endregion
        #region LastWorkItemResultId

        private System.Nullable<int> _LastWorkItemResultId;
        public System.Nullable<int> LastWorkItemResultId
        { 
            get
            {
                return _LastWorkItemResultId;
            }
            set
            {
                _LastWorkItemResultId = value;
            }
        }

        #endregion
        #region LogDayCount

        private int _LogDayCount;
        public int LogDayCount
        { 
            get
            {
                return _LogDayCount;
            }
            set
            {
                _LogDayCount = value;
            }
        }

        #endregion
        #region LogModeId

        private int _LogModeId;
        public int LogModeId
        { 
            get
            {
                return _LogModeId;
            }
            set
            {
                _LogModeId = value;
            }
        }

        #endregion
        #region Name

        private string _Name;
        public string Name
        { 
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        #endregion
        #region RetryCount

        private int _RetryCount;
        public int RetryCount
        { 
            get
            {
                return _RetryCount;
            }
            set
            {
                _RetryCount = value;
            }
        }

        #endregion
        #region RetryTime

        private System.Nullable<System.DateTime> _RetryTime;
        public System.Nullable<System.DateTime> RetryTime
        { 
            get
            {
                return _RetryTime;
            }
            set
            {
                _RetryTime = Sidvall.Business.ValidationManager.GetValidUniversalDateTime(value, System.DateTimeKind.Utc);
            }
        }

        #endregion
        #region SensorLogDayCount

        private int _SensorLogDayCount;
        public int SensorLogDayCount
        { 
            get
            {
                return _SensorLogDayCount;
            }
            set
            {
                _SensorLogDayCount = value;
            }
        }

        #endregion
        #region WorkerId

        private long _WorkerId;
        public long WorkerId
        { 
            get
            {
                return _WorkerId;
            }
            set
            {
                _WorkerId = value;
            }
        }

        #endregion
        #region WorkItemContext

        private string _WorkItemContext;
        public string WorkItemContext
        { 
            get
            {
                return _WorkItemContext;
            }
            set
            {
                _WorkItemContext = value;
            }
        }

        #endregion
        #region WorkItemId

        private long _WorkItemId;
        public long WorkItemId
        { 
            get
            {
                return _WorkItemId;
            }
            set
            {
                _WorkItemId = value;
            }
        }

        #endregion
        #region WorkItemStatusId

        private int _WorkItemStatusId;
        public int WorkItemStatusId
        { 
            get
            {
                return _WorkItemStatusId;
            }
            set
            {
                _WorkItemStatusId = value;
            }
        }

        #endregion
        #region WorkItemTypeId

        private System.Nullable<long> _WorkItemTypeId;
        public System.Nullable<long> WorkItemTypeId
        { 
            get
            {
                return _WorkItemTypeId;
            }
            set
            {
                _WorkItemTypeId = value;
            }
        }

        #endregion
        #region WorkRetryPolicyContext

        private string _WorkRetryPolicyContext;
        public string WorkRetryPolicyContext
        { 
            get
            {
                return _WorkRetryPolicyContext;
            }
            set
            {
                _WorkRetryPolicyContext = value;
            }
        }

        #endregion
        #region WorkRetryPolicyId

        private System.Nullable<long> _WorkRetryPolicyId;
        public System.Nullable<long> WorkRetryPolicyId
        { 
            get
            {
                return _WorkRetryPolicyId;
            }
            set
            {
                _WorkRetryPolicyId = value;
            }
        }

        #endregion
        
        public virtual Sidvall.WorkItemManager.Data.Entity.Entities.Worker Worker { get; set; }
        public virtual Sidvall.WorkItemManager.Data.Entity.Entities.WorkItemType WorkItemType { get; set; }
        public virtual Sidvall.WorkItemManager.Data.Entity.Entities.WorkRetryPolicy WorkRetryPolicy { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.WorkItemManager.Data.Entity.Entities.WorkItemLog> WorkItemLog { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.WorkItemManager.Data.Entity.Entities.WorkItemSensor> WorkItemSensor { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.WorkItemManager.Data.Entity.Entities.WorkItemWorkCondition> WorkItemWorkCondition { get; set; }
        
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.WorkItemManager.Data.Entity.SystemContext.Current.EntityFacade.WorkItemManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.WorkItemManager.Data.Entity.SystemContext.Current.EntityFacade.WorkItemManager.DataRowStateIsDirty(this);
            }
        }

        #endregion

        #region IWorkItem Members

        global::Sidvall.WorkItemManager.Workflow.ThreadAction global::Sidvall.WorkItemManager.Data.IWorkItem.CanceledAction
        {
            get
            {
                return (global::Sidvall.WorkItemManager.Workflow.ThreadAction)this._CanceledAction;
            }
            set
            {
                this.CanceledAction = (int)value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.Description
        {
            get
            {
                return this._Description;
            }
            set
            {
                this.Description = value;
            }
        }
        byte global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionCompletionPercentage
        {
            get
            {
                return this._ExecutionCompletionPercentage;
            }
            set
            {
                this.ExecutionCompletionPercentage = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionContext
        {
            get
            {
                return this._ExecutionContext;
            }
            set
            {
                this.ExecutionContext = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionContextUpdated
        {
            get
            {
                return this._ExecutionContextUpdated;
            }
            set
            {
                this.ExecutionContextUpdated = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionOrder
        {
            get
            {
                return this._ExecutionOrder;
            }
            set
            {
                this.ExecutionOrder = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionStartTime
        {
            get
            {
                return this._ExecutionStartTime;
            }
            set
            {
                this.ExecutionStartTime = value;
            }
        }
        global::Sidvall.WorkItemManager.Workflow.ThreadAction global::Sidvall.WorkItemManager.Data.IWorkItem.FailedAction
        {
            get
            {
                return (global::Sidvall.WorkItemManager.Workflow.ThreadAction)this._FailedAction;
            }
            set
            {
                this.FailedAction = (int)value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.FailedExecutionCount
        {
            get
            {
                return this._FailedExecutionCount;
            }
            set
            {
                this.FailedExecutionCount = value;
            }
        }
        bool global::Sidvall.WorkItemManager.Data.IWorkItem.ForceExecution
        {
            get
            {
                return this._ForceExecution;
            }
            set
            {
                this.ForceExecution = value;
            }
        }
        bool global::Sidvall.WorkItemManager.Data.IWorkItem.IsCanceled
        {
            get
            {
                return this._IsCanceled;
            }
            set
            {
                this.IsCanceled = value;
            }
        }
        bool global::Sidvall.WorkItemManager.Data.IWorkItem.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this.IsEnabled = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.LastExecutionEndTime
        {
            get
            {
                return this._LastExecutionEndTime;
            }
            set
            {
                this.LastExecutionEndTime = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.LastExecutionStartTime
        {
            get
            {
                return this._LastExecutionStartTime;
            }
            set
            {
                this.LastExecutionStartTime = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.LastResultMessage
        {
            get
            {
                return this._LastResultMessage;
            }
            set
            {
                this.LastResultMessage = value;
            }
        }
        System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType> global::Sidvall.WorkItemManager.Data.IWorkItem.LastWorkItemResultId
        {
            get
            {
                return (System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType>)this._LastWorkItemResultId;
            }
            set
            {
                this.LastWorkItemResultId = (System.Nullable<int>)value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.LogDayCount
        {
            get
            {
                return this._LogDayCount;
            }
            set
            {
                this.LogDayCount = value;
            }
        }
        global::Sidvall.WorkItemManager.Workflow.LogModes global::Sidvall.WorkItemManager.Data.IWorkItem.LogModeId
        {
            get
            {
                return (global::Sidvall.WorkItemManager.Workflow.LogModes)this._LogModeId;
            }
            set
            {
                this.LogModeId = (int)value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this.Name = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.RetryCount
        {
            get
            {
                return this._RetryCount;
            }
            set
            {
                this.RetryCount = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.RetryTime
        {
            get
            {
                return this._RetryTime;
            }
            set
            {
                this.RetryTime = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.SensorLogDayCount
        {
            get
            {
                return this._SensorLogDayCount;
            }
            set
            {
                this.SensorLogDayCount = value;
            }
        }
        long global::Sidvall.WorkItemManager.Data.IWorkItem.WorkerId
        {
            get
            {
                return this._WorkerId;
            }
            set
            {
                this.WorkerId = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemContext
        {
            get
            {
                return this._WorkItemContext;
            }
            set
            {
                this.WorkItemContext = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemId
        {
            get
            {
                return this._WorkItemId;
            }
            set
            {
                if (value != null)
                    this.WorkItemId = value.Value;
            }
        }
        global::Sidvall.WorkItemManager.Workflow.WorkItemStatus global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemStatusId
        {
            get
            {
                return (global::Sidvall.WorkItemManager.Workflow.WorkItemStatus)this._WorkItemStatusId;
            }
            set
            {
                this.WorkItemStatusId = (int)value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemTypeId
        {
            get
            {
                return this._WorkItemTypeId;
            }
            set
            {
                this.WorkItemTypeId = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.WorkRetryPolicyContext
        {
            get
            {
                return this._WorkRetryPolicyContext;
            }
            set
            {
                this.WorkRetryPolicyContext = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkRetryPolicyId
        {
            get
            {
                return this._WorkRetryPolicyId;
            }
            set
            {
                this.WorkRetryPolicyId = value;
            }
        }
        System.Nullable<System.Int32> global::Sidvall.WorkItemManager.Data.IWorkItem.ServerConnectionId
        {
            get
            {
                return null;
            }
            set
            {
            }
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        IWorker global::Sidvall.WorkItemManager.Data.IWorkItem.Worker
        {
            get
            {
                return this.Worker;
            }
            set
            {
                this.Worker = value as Worker;
            }
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        IWorkItemType global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemType
        {
            get
            {
                return this.WorkItemType;
            }
            set
            {
                this.WorkItemType = value as WorkItemType;
            }
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        IWorkRetryPolicy global::Sidvall.WorkItemManager.Data.IWorkItem.WorkRetryPolicy
        {
            get
            {
                return this.WorkRetryPolicy;
            }
            set
            {
                this.WorkRetryPolicy = value as WorkRetryPolicy;
            }
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IWorkItemLog> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemLogs
        {
            get
            {
                return this.WorkItemLog;
            }
        }
        void global::Sidvall.WorkItemManager.Data.IWorkItem.SetWorkItemLogs(Sidvall.Data.IDataRowProvider<global::Sidvall.WorkItemManager.Data.IWorkItemLog> items)
        {
            this.WorkItemLog = items as WorkItemLogCollection;
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IWorkItemSensor> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemSensors
        {
            get
            {
                return this.WorkItemSensor;
            }
        }
        void global::Sidvall.WorkItemManager.Data.IWorkItem.SetWorkItemSensors(Sidvall.Data.IDataRowProvider<global::Sidvall.WorkItemManager.Data.IWorkItemSensor> items)
        {
            this.WorkItemSensor = items as WorkItemSensorCollection;
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IWorkItemWorkCondition> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemWorkConditions
        {
            get
            {
                return this.WorkItemWorkCondition;
            }
        }
        void global::Sidvall.WorkItemManager.Data.IWorkItem.SetWorkItemWorkConditions(Sidvall.Data.IDataRowProvider<global::Sidvall.WorkItemManager.Data.IWorkItemWorkCondition> items)
        {
            this.WorkItemWorkCondition = items as WorkItemWorkConditionCollection;
        }

        #endregion

        #endregion
        #region Constructors

        public WorkItem() : this(false, null, null)
        {
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public WorkItem(bool initializeChildren, Sidvall.Data.IDataRowContextProvider context, Sidvall.Data.DataRowState? dataRowState)
        {
            if ((context != null) || (dataRowState != null))
                SetDataRowContext(context, dataRowState);
            if (initializeChildren)
            {
                this.WorkItemLog = new System.Collections.Generic.List<WorkItemLog>();
                this.WorkItemSensor = new System.Collections.Generic.List<WorkItemSensor>();
                this.WorkItemWorkCondition = new System.Collections.Generic.List<WorkItemWorkCondition>();
            }
        }

        #endregion
    }
}